# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=nauty
epoch=1
pkgver=2.8.6
pkgrel=2
pkgdesc='A program for computing automorphism groups of graphs and digraphs'
arch=(loong64 x86_64)
url='http://pallini.di.uniroma1.it/'
license=(Apache)
depends=(glibc)
source=(http://pallini.di.uniroma1.it/nauty${pkgver//./_}.tar.gz
        nauty-2.8.6-gentreeg-gentourng.patch)
sha256sums=('f2ce98225ca8330f5bce35f7d707b629247e09dda15fc479dc00e726fee5e6fa'
            '2a6ae62a3064d24513442a094fe6db41c6733cb5259172350791819be7bf3c11')
 
prepare() {
  patch -d nauty${pkgver//./_} -p1 < nauty-2.8.6-gentreeg-gentourng.patch # Fix gentreeg and gentourg for 2 vertices (Gentoo)
}

build() {
  cd nauty${pkgver//./_}

  export CFLAGS+=' -fPIC -ffat-lto-objects'
  ./configure --enable-generic
  make
}

package() {
  cd nauty${pkgver//./_}

  mkdir -p "$pkgdir"/usr/bin
  for _program in addedgeg amtog biplabg catg complg converseg copyg countg cubhamg deledgeg delptg directg dreadnaut dretodot dretog \
    genbg genbgL geng genquarticg genrang genspecialg gentourng gentreeg hamheuristic labelg linegraphg listg multig newedgeg \
    pickg planarg ranlabg shortg showg subdivideg twohamg vcolg watercluster2 NRswitchg;
  do
   install -m755 $_program "$pkgdir"/usr/bin/$program
  done
  install -Dm644 nauty.a "$pkgdir"/usr/lib/libnauty.a
  install -Dm644 *.h -t "$pkgdir"/usr/include/nauty

  mkdir -p "$pkgdir"/usr/share/licenses/nauty
  install COPYRIGHT "$pkgdir"/usr/share/licenses/nauty/LICENSE
}
